/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.src.ptit.javatraining.huynh.btvn2;

import java.util.Scanner;

/**
 *
 * @author user
 */
public class IO {

    public void nhapInteger() {
        Scanner sc = new Scanner(System.in);
        String s;
        int a;
        try {
            s = sc.nextLine();
            if (s.length() < 1) {
                throw new Exception("Xau rong !");
            }
            a = Integer.parseInt(s);
        } catch (Exception e) {
            System.out.println("Error " + e);
        }
    }

    public void nhapFloat() {
        Scanner sc = new Scanner(System.in);
        String s;
        float a;
        try {
            s = sc.nextLine();
            if (s.length() < 1) {
                throw new Exception("Xau rong !");
            }
            a = Float.parseFloat(s);
        } catch (Exception e) {
            System.out.println("Error " + e);
        }
    }

    public void nhapDouble() {
        Scanner sc = new Scanner(System.in);
        String s;
        double a;
        try {
            s = sc.nextLine();
            if (s.length() < 1) {
                throw new Exception("Xau rong !");
            }
            a = Double.parseDouble(s);
        } catch (Exception e) {
            System.out.println("Error " + e);
        }
    }

    public void nhapString() {
        Scanner sc = new Scanner(System.in);
        String s;
        try {
            s = sc.nextLine();
            if (s.length() < 1) {
                throw new Exception("Xau rong !");
            }
        } catch (Exception e) {
            System.out.println("Error " + e);
        }
    }
}
